<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--报名表单-->
<div class="pcformbm">
    <div class="w1000">
        <span class="iconbm">申请免费名师测评</span>
        姓名：<input type="text" class="forminput" name="uname" id="uname">
        年级：<select class="forminput2" name="ugrade" id="ugrade">
        <option value="">请选择年级</option>
        <option value="预初">预初</option>
        <option value="初一">初一</option>
        <option value="初二">初二</option>
        <option value="初三">初三</option>
        <option value="高一">高一</option>
        <option value="高二">高二</option>
        <option value="高三">高三</option>
    </select>
        手机：<input type="text" class="forminput" name="uphone" id="uphone">

        <button type="submit" class="btncheng" id="fmbtn" onclick="return CheckAll();">立即提交</button>
    </div>
    <div id="btn-dialogBox"></div>

    <script type="text/javascript">
        function mess(info) {
            $('#btn-dialogBox').dialogBox({
                width: 300,
                height: 200,
                autoHide: true,
                time: 1500,
                effect: 'flip-horizontal',
                //title: 'title text',
                content: '<img src="img/ifau.png"><br/><br/>' + info
            });
        }

        function CheckAll() {
            if ($("#uname").val() == "") {
                mess("用户名不能为空！");
                $("#uname").focus();
                return false;
            }
            if (!/^[\u4e00-\u9fa5]{2,5}$/.test($("#uname").val())) {
                mess("姓名必须是中文");
                $("#uname").focus();
                return false;
            }
            if ($("#ugrade option:selected").attr("value") == "") {
                mess("所在年级不能为空！");
                $("#ugrade").focus();
                return false;
            }
            if (!/^1[3|4|5|7|8]\d{9}$/.test($("#uphone").val())) {
                mess("请填写正确的手机号码");
                $("#uphone").focus();
                return false;
            }
            //AJAX数据提交
            $.ajax({
                type: "POST",
                url: "/index.php/portal/order/index",
                data: {
                    uname: $("#uname").val(),
                    uphone: $("#uphone").val(),
                    ugrade: $("#ugrade").val()
                },
                cache: false,
                dataType: 'json',
                beforeSend: function () {
                    $("#fmbtn").html("数据提交中，请稍后...");
                },
                success: function (data) {
                    if (data.code == "true") {
                        alert(data.msg);
//				             window.location.reload();
                        $("input").val("");
                        $("#fmbtn").html("立即提交");
                    } else {
                        view(data.msg);
                    }
                },
                error: function () {
                    alert("异常！");
                }
            });
        }

    </script>
</div>
</body>
</html>